package com.mentaleye.service.impl;

import com.mentaleye.bean.InterflowBean;
import com.mentaleye.dal.dao.InterflowDao;
import com.mentaleye.dal.model.Interflow;
import com.mentaleye.dal.model.InterflowExample;
import com.mentaleye.service.InterflowService;
import com.mentaleye.util.CommonPage;
import com.mentaleye.util.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by Rock on 2017/5/12.
 */
@Service
public class InterflowServiceImpl implements InterflowService{

    @Autowired private InterflowDao interflowDao;

    public boolean add(InterflowBean bean){
        return interflowDao.add((Interflow) ObjectUtil.transfer(bean,Interflow.class));
    }

    public boolean edit(InterflowBean bean){
        return interflowDao.update((Interflow) ObjectUtil.transfer(bean,Interflow.class));
    }

    public boolean editByExample(InterflowBean bean, InterflowExample example){
        return interflowDao.updateByExample((Interflow) ObjectUtil.transfer(bean,Interflow.class),example);
    }

    public boolean remove(Integer interflowId){
        return interflowDao.delete(interflowId);
    }

    public boolean removeByExample(InterflowExample example){
        return interflowDao.deleteByExample(example);
    }

    public InterflowBean query(Integer interflowId){
        return (InterflowBean)ObjectUtil.transfer(interflowDao.select(interflowId),InterflowBean.class);
}

    public List<InterflowBean> queryByExample(InterflowExample example){
        return (List<InterflowBean>)ObjectUtil.transferList(interflowDao.selectByExample(example),InterflowBean.class);
    }

    public List<Map<String, Object>> queryNotStudent(){
        return interflowDao.selectNotStudent();
    }

    public void queryByCommpage(CommonPage commonPage){
        List<Map<String, Object>> interflowList = interflowDao.selectByMap(commonPage.pageToMap());
        commonPage.setPageData(interflowList);
    }
}
